using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class SettingPanel : BaseView
{
    private Slider sliderMusic;
    private Slider sliderSound;

    public void Start()
    {
        //设置初始值
        sliderMusic = transform.Find("sliders/music/slider").GetComponent<Slider>();
        sliderMusic.value = PlayerPrefs.GetFloat(Const.musicValue,1.0f);
        sliderSound = transform.Find("sliders/sound/slider").GetComponent<Slider>();
        sliderSound.value = PlayerPrefs.GetFloat(Const.soundValue,1.0f);
        
        //设置 监听函数
        sliderMusic.onValueChanged.AddListener(OnMusicValueChange);
        sliderSound.onValueChanged.AddListener(OnSoundValueChange);
    }
    
    public void OnSoundValueChange(float val)
    {
        PlayerPrefs.SetFloat(Const.soundValue, val);
    }
    public void OnMusicValueChange(float val)
    {
        PlayerPrefs.SetFloat(Const.musicValue, val);
    }
}
